import numpy as np
import plotly.graph_objs as go

a = np.linspace(-1, 1, 31)
b = np.linspace(-1, 1, 31)
x, y = np.meshgrid(a, b)
print("使用说明：\n1.乘方用**2代替，三次是**3，以此类推\n2.乘号不可以省略，写成*，如xy写x*y\n3.不能出现xyz以外的字母\n4.等号左边要有且只有一个字母")
while True:
    exec(input("输入解析式（z=...):"))
    C = {"z": {"show": True, "start": -1, "end": 1,
               "size": 0.2, "usecolormap": True, "project_z": True, "highlightcolor": "limegreen"}}
    D = go.Surface(x=x, y=y, z=z, opacity=0.8, contours=C)
    L = go.Layout(scene={"xaxis": {"nticks": 20}, 'camera_eye': {"x": 0, "y": -1, "z": 0.5},
                         "aspectratio": {"x": 1, "y": 1, "z": 0.5}})
    F = go.Figure(data=D, layout=L)
    F.show()
